import sys
import itertools

if len(sys.argv) < 2:
    print("Please input one file!")
    sys.exit(1)

def check_conflict(file1, file2):
    diffFlag = False
    with open(file1, 'r') as f1, open(file2, 'r') as f2:
        for line1, line2 in zip(f1, f2):
            folder1, filename1, result1 = line1.strip().replace(" ", "").split(',')
            folder2, filename2, result2 = line2.strip().replace(" ", "").split(',')

            # print('+'+result1+'+', '+'+result2+'+')
            if (result1 == 'Unrealizable' or result1 == 'Realizable') and (result2 == 'Unrealizable' or result2 == 'Realizable'):
                if result1 != result2:
                    diffFlag = True
                    print((folder1+'/'+filename1).ljust(18), result1, result2)
    return diffFlag

input_file = sys.argv[1]
compare_lists = [
    '/public/home/jwli/workSpace/yongkang/AAAI-24July-labs/experiments_from_24.0726/lab_results_parser/experiment_results/experiment_raw_csv-5min/ltlfsyn-combine-fixTarjan2.csv',
    '/public/home/jwli/workSpace/yongkang/AAAI-24July-labs/experiments_from_24.0726/lab_results_parser/experiment_results/experiment_raw_csv-5min/ltlfsyn-raw-fixTarjan2.csv',
    '/public/home/jwli/workSpace/yongkang/AAAI-24July-labs/experiments_from_24.0726/lab_results_parser/experiment_results/experiment_raw_csv-5min/ltlfsyn-combine-simple_nowholeDFA-ERROR.csv',
    '/public/home/jwli/workSpace/yongkang/AAAI-24July-labs/experiments_from_24.0726/lab_results_parser/experiment_results/experiment_raw_csv-5min/lydia.csv',
    '/public/home/jwli/workSpace/yongkang/AAAI-24July-labs/experiments_from_24.0726/lab_results_parser/experiment_results/experiment_raw_csv-5min/nike.csv',
    '/public/home/jwli/workSpace/yongkang/AAAI-24July-labs/experiments_from_24.0726/parallel-24.0805-syntcomp-5min/bench_sys_SATtrace-24.0805_release-combine01_e69fd06/output_syntcomp23_ltlfsynSyft.csv',
    '/public/home/jwli/workSpace/yongkang/AAAI-24July-labs/experiments_from_24.0810/parallel-24.0810-syntcomp-30min/bench_sys_COMBINE01-raw-24.0811_9ddc125/output_syntcomp23_ltlfsynSyft.csv',
]

has_conflict_flag = False
for compare_file in compare_lists:
    if check_conflict(input_file, compare_file):
        print("Conflicts found compared to \n\t{} \n\t are as above!!!".format(compare_file))
        has_conflict_flag = True

if not has_conflict_flag:
    print("No conflicts found.")
